package org.drushpal
{
	import flash.display.DisplayObjectContainer;
	
	import org.drushpal.model.ConnectionModel;
	import org.drushpal.model.RepositoryModel;
	import org.drushpal.model.SettingsModel;
	import org.drushpal.model.enum.DrushCommand;
	import org.drushpal.service.DrushService;
	import org.drushpal.service.commands.CronCommand;
	import org.drushpal.service.commands.DownloadCommand;
	import org.drushpal.service.commands.DrushCommandEvent;
	import org.drushpal.service.commands.ListCommand;
	import org.drushpal.service.commands.OpenSettingsCommand;
	import org.drushpal.service.commands.RefreshCommand;
	import org.drushpal.service.commands.StatusCommand;
	import org.drushpal.service.commands.VGetCommand;
	import org.drushpal.view.ControlPanel;
	import org.drushpal.view.ControlPanelMediator;
	import org.drushpal.view.forms.ConnectionForm;
	import org.drushpal.view.forms.ConnectionFormMediator;
	import org.drushpal.view.forms.SettingsForm;
	import org.drushpal.view.forms.SettingsFormMediator;
	import org.drushpal.view.panels.BrowserPanel;
	import org.drushpal.view.panels.BrowserPanelMediator;
	import org.drushpal.view.panels.HistoryPanel;
	import org.drushpal.view.panels.HistoryPanelMediator;
	import org.drushpal.view.panels.TerminalPanel;
	import org.drushpal.view.panels.TerminalPanelMediator;
	import org.drushpal.view.tabs.ModulesTab;
	import org.drushpal.view.tabs.ModulesTabMediator;
	import org.drushpal.view.tabs.StatusTab;
	import org.drushpal.view.tabs.StatusTabMediator;
	import org.drushpal.view.tabs.VariablesTab;
	import org.drushpal.view.tabs.VariablesTabMediator;
	import org.robotlegs.mvcs.Context;
	
	public class DrushPalContext extends Context
	{
		override public function startup():void{
			
			injector.mapSingleton(RepositoryModel);
			injector.mapSingleton(ConnectionModel);
			injector.mapSingleton(SettingsModel);
			injector.mapSingleton(DrushService);
			
			commandMap.mapEvent(DrushPalEvent.OPEN_SETTINGS,OpenSettingsCommand,DrushPalEvent);
			
			//Drush related commands
			commandMap.mapEvent(DrushCommand.STATUS,StatusCommand,DrushCommandEvent);
			commandMap.mapEvent(DrushCommand.REFRESH,RefreshCommand,DrushCommandEvent);
			commandMap.mapEvent(DrushCommand.LIST,ListCommand,DrushCommandEvent);
			commandMap.mapEvent(DrushCommand.CRON,CronCommand,DrushCommandEvent);
			commandMap.mapEvent(DrushCommand.DOWNLOAD,DownloadCommand);
			commandMap.mapEvent(DrushCommand.VARIABLE_GET,VGetCommand,DrushCommandEvent);
			
			mediatorMap.mapView(DrushPal,DrushPalMediator);
			
			mediatorMap.mapView(ConnectionForm,ConnectionFormMediator,null,false,false);//popup mediators are done manually
			mediatorMap.mapView(SettingsForm,SettingsFormMediator,null,false,false);
			
			mediatorMap.mapView(ControlPanel,ControlPanelMediator);//popup mediators are done manually
				//Control tabs
				mediatorMap.mapView(StatusTab,StatusTabMediator);
				mediatorMap.mapView(ModulesTab,ModulesTabMediator);
				mediatorMap.mapView(VariablesTab,VariablesTabMediator);
				//Control panels
				mediatorMap.mapView(TerminalPanel,TerminalPanelMediator);
				mediatorMap.mapView(HistoryPanel,HistoryPanelMediator);
				mediatorMap.mapView(BrowserPanel,BrowserPanelMediator);
			
			
			super.startup();  
		}
	}
}